home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8706 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Combine zero-offset with unit-offset arrays ?
  5. Date: Tue, 05 Mar 96 17:14:26 GMT
  6. Organization: none
  7. Message-ID: <826046066snz@genesis.demon.co.uk>
  8. References: <4hes0h$52qi@info4.rus.uni-stuttgart.de> <4hfau5INNme5@keats.ugrad.cs.ubc.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4hfau5INNme5@keats.ugrad.cs.ubc.ca>
  15.            c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
  16.  
  17. >#define fa(x) (fa[x-1])
  18.  
  19. That should be (fa[(x)-1])
  20.  
  21. >{
  22. >        int foo = fa(1);
  23. >}
  24. >
  25. >which now gives you fa[1-1], which is *((fa) + 1 - 1).
  26.  
  27. Or rather it is *(fa + (1-1))
  28.  
  29. >This is defined. The
  30. >standard allows you generate a pointer which references one element past the
  31. >end of the array, thus if you put in the subscript 10,  you would have
  32. >*((fa) + 10 - 1).
  33.  
  34. That's not an ussue in this case since 1 is subtracted before the value is
  35. added to the pointer. So this method works for offsets other than 0 or 1.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.